package com.itheima.d3_inner_class3;

public class Test1 {
    public static void main(String[] args) {
        // 目标：认识匿名内部类，并掌握其作用。

        //new Animal();
        new Animal(){
            @Override
            public void cry() {
                System.out.println("汪汪汪的叫！");
            }
        };

        //多态
        Animal a = new Animal() {
            @Override
            public void cry() {
                System.out.println("咯咯咯的叫");
            }
        };

        a.cry();

        //接口的匿名内部类
        new Fly(){
            @Override
            public void fly() {
                System.out.println("小鸟在飞翔！！");
            }
        };
    }
}


abstract class Animal {
    public abstract void cry();
}

interface Fly{
    void fly();
}

class Bird implements Fly{
    @Override
    public void fly() {

    }
}